home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / Development / PowerD / Pdmod / modules / sys / socket.m < prev    next >
Encoding:
Text File  |  2002-10-28  |  10.6 KB  |  278 lines

  1. /*
  2.  * $Id: socket.h,v 3.1 1994/01/24 16:06:03 too Exp $
  3.  *
  4.  * Copyright (c) 1993 AmiTCP/IP Group, <amitcp-group@hut.fi>
  5.  *                    Helsinki University of Technology, Finland.
  6.  *                    All rights reserved.
  7.  *
  8.  * HISTORY
  9.  * $Log: socket.h,v $
  10.  * Revision 3.1  1994/01/24  16:06:03  too
  11.  * Added definition of `struct iovec'
  12.  *
  13.  * Revision 1.11  1993/07/07  14:55:52  too
  14.  * Removed inclusion of CLIB_SOCKET_PROTOS_H
  15.  *
  16.  * Revision 1.10  1993/06/04  11:16:15  jraja
  17.  * Fixes for first public release.
  18.  *
  19.  * Revision 1.9  1993/06/01  08:12:25  jraja
  20.  * Added definition UNIQUE_ID to be used with Release(CopyOf)Socket().
  21.  *
  22.  * Revision 1.6  1993/04/26  11:22:59  jraja
  23.  * Updated to include socket protos/pragmas/inlines (if not in KERNEL).
  24.  *
  25.  * Revision 1.5  93/04/13  21:59:15  21:59:15  jraja (Jarno Tapio Rajahalme)
  26.  * Added inline/prototype for Select() function (#ifndef KERNEL).
  27.  * 
  28.  * Revision 1.4  93/03/22  01:25:21  01:25:21  ppessi (Pekka Pessi)
  29.  * An API version of socket.h
  30.  * 
  31.  * Revision 1.1  92/11/20  15:42:36  15:42:36  jraja (Jarno Tapio Rajahalme)
  32.  * Initial revision
  33.  *
  34.  */
  35.  
  36. /*
  37.  * Copyright (c) 1982,1985,1986,1988 Regents of the University of California.
  38.  * All rights reserved.
  39.  *
  40.  * Redistribution and use in source and binary forms, with or without
  41.  * modification, are permitted provided that the following conditions
  42.  * are met:
  43.  * 1. Redistributions of source code must retain the above copyright
  44.  *    notice, this list of conditions and the following disclaimer.
  45.  * 2. Redistributions in binary form must reproduce the above copyright
  46.  *    notice, this list of conditions and the following disclaimer in the
  47.  *    documentation and/or other materials provided with the distribution.
  48.  * 3. All advertising materials mentioning features or use of this software
  49.  *    must display the following acknowledgement:
  50.  *      This product includes software developed by the University of
  51.  *      California, Berkeley and its contributors.
  52.  * 4. Neither the name of the University nor the names of its contributors
  53.  *    may be used to endorse or promote products derived from this software
  54.  *    without specific prior written permission.
  55.  *
  56.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  57.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  58.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  59.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  60.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  61.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  62.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  63.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  64.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  65.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  66.  * SUCH DAMAGE.
  67.  *
  68.  *      @(#)socket.h    7.13 (Berkeley) 4/20/91
  69.  */
  70.  
  71. /*
  72.  * Definitions related to sockets: types, address families, options.
  73.  */
  74.  
  75. /*
  76.  * Definition for Release(CopyOf)Socket unique id
  77.  */
  78. #define UNIQUE_ID       -1
  79.  
  80. /*
  81.  * Types
  82.  */
  83. #define SOCK_STREAM     1               /* stream socket */
  84. #define SOCK_DGRAM      2               /* datagram socket */
  85. #define SOCK_RAW        3               /* raw-protocol interface */
  86. #define SOCK_RDM        4               /* reliably-delivered message */
  87. #define SOCK_SEQPACKET  5               /* sequenced packet stream */
  88.  
  89. /*
  90.  * Option flags per-socket.
  91.  */
  92. #define SO_DEBUG        $0001          /* turn on debugging info recording */
  93. #define SO_ACCEPTCONN   $0002          /* socket has had listen() */
  94. #define SO_REUSEADDR    $0004          /* allow local address reuse */
  95. #define SO_KEEPALIVE    $0008          /* keep connections alive */
  96. #define SO_DONTROUTE    $0010          /* just use interface addresses */
  97. #define SO_BROADCAST    $0020          /* permit sending of broadcast msgs */
  98. #define SO_USELOOPBACK  $0040          /* bypass hardware when possible */
  99. #define SO_LINGER       $0080          /* linger on close if data present */
  100. #define SO_OOBINLINE    $0100          /* leave received OOB data in line */
  101.  
  102. /*
  103.  * Additional options, not kept in so_options.
  104.  */
  105. #define SO_SNDBUF       $1001          /* send buffer size */
  106. #define SO_RCVBUF       $1002          /* receive buffer size */
  107. #define SO_SNDLOWAT     $1003          /* send low-water mark */
  108. #define SO_RCVLOWAT     $1004          /* receive low-water mark */
  109. #define SO_SNDTIMEO     $1005          /* send timeout */
  110. #define SO_RCVTIMEO     $1006          /* receive timeout */
  111. #define SO_ERROR        $1007          /* get error status and clear */
  112. #define SO_TYPE         $1008          /* get socket type */
  113.  
  114. /*
  115.  * Structure used for manipulating linger option.
  116.  */
  117. OBJECT linger
  118.     l_onoff:LONG,               /* option on/off */
  119.     l_linger:LONG               /* linger time */
  120.  
  121. /*
  122.  * Level number for (get/set)sockopt() to apply to socket itself.
  123.  */
  124. #define SOL_SOCKET      $ffff          /* options for socket level */
  125.  
  126. /*
  127.  * Address families.
  128.  */
  129. #define AF_UNSPEC       0               /* unspecified */
  130. #define AF_UNIX         1               /* local to host (pipes, portals) */
  131. #define AF_INET         2               /* internetwork: UDP, TCP, etc. */
  132. #define AF_IMPLINK      3               /* arpanet imp addresses */
  133. #define AF_PUP          4               /* pup protocols: e.g. BSP */
  134. #define AF_CHAOS        5               /* mit CHAOS protocols */
  135. #define AF_NS           6               /* XEROX NS protocols */
  136. #define AF_ISO          7               /* ISO protocols */
  137. #define AF_OSI          AF_ISO
  138. #define AF_ECMA         8               /* european computer manufacturers */
  139. #define AF_DATAKIT      9               /* datakit protocols */
  140. #define AF_CCITT        10              /* CCITT protocols, X.25 etc */
  141. #define AF_SNA          11              /* IBM SNA */
  142. #define AF_DECnet       12              /* DECnet */
  143. #define AF_DLI          13              /* DEC Direct data link interface */
  144. #define AF_LAT          14              /* LAT */
  145. #define AF_HYLINK       15              /* NSC Hyperchannel */
  146. #define AF_APPLETALK    16              /* Apple Talk */
  147. #define AF_ROUTE        17              /* Internal Routing Protocol */
  148. #define AF_LINK         18              /* Link layer interface */
  149. #define pseudo_AF_XTP   19              /* eXpress Transfer Protocol (no AF) */
  150.  
  151. #define AF_MAX          20
  152.  
  153. /*
  154.  * Structure used by kernel to store most
  155.  * addresses.
  156.  */
  157. OBJECT sockaddr
  158.     sa_len:UBYTE,                 /* total length */
  159.     sa_family:UBYTE,              /* address family */
  160.     sa_data[14]:BYTE             /* actually longer; address value */
  161.  
  162. /*
  163.  * Structure used by kernel to pass protocol
  164.  * information in raw sockets.
  165.  */
  166. OBJECT sockproto
  167.     sp_family:UWORD,              /* address family */
  168.     sp_protocol:UWORD            /* protocol */
  169.  
  170. /*
  171.  * Protocol families, same as address families for now.
  172.  */
  173.  
  174. #define PF_UNSPEC       AF_UNSPEC
  175. #define PF_UNIX         AF_UNIX
  176. #define PF_INET         AF_INET
  177. #define PF_IMPLINK      AF_IMPLINK
  178. #define PF_PUP          AF_PUP
  179. #define PF_CHAOS        AF_CHAOS
  180. #define PF_NS           AF_NS
  181. #define PF_ISO          AF_ISO
  182. #define PF_OSI          AF_ISO
  183. #define PF_ECMA         AF_ECMA
  184. #define PF_DATAKIT      AF_DATAKIT
  185. #define PF_CCITT        AF_CCITT
  186. #define PF_SNA          AF_SNA
  187. #define PF_DECnet       AF_DECnet
  188. #define PF_DLI          AF_DLI
  189. #define PF_LAT          AF_LAT
  190. #define PF_HYLINK       AF_HYLINK
  191. #define PF_APPLETALK    AF_APPLETALK
  192. #define PF_ROUTE        AF_ROUTE
  193. #define PF_LINK         AF_LINK
  194. #define PF_XTP          pseudo_AF_XTP   /* really just proto family, no AF */
  195.  
  196. #define PF_MAX          AF_MAX
  197.  
  198. /*
  199.  * Maximum queue length specifiable by listen.
  200.  */
  201. #define SOMAXCONN       5
  202.  
  203. /*
  204.  * Message header for recvmsg and sendmsg calls.
  205.  * Used value-result for recvmsg, value only for sendmsg.
  206.  */
  207. OBJECT iovec
  208.         iov_base:PTR TO BYTE,
  209.         iov_len:LONG
  210.  
  211. OBJECT msghdr
  212.     msg_name:PTR TO BYTE,               /* optional address */
  213.     msg_namelen:ULONG,            /* size of address */
  214.     msg_iov:PTR TO iovec,         /* scatter/gather array */
  215.     msg_iovlen:ULONG,             /* # elements in msg_iov */
  216.     msg_control:PTR TO BYTE,            /* ancillary data, see below */
  217.     msg_controllen:ULONG,         /* ancillary data buffer len */
  218.     msg_flags:LONG              /* flags on received message */
  219.  
  220.  
  221. #define MSG_OOB         $1             /* process out-of-band data */
  222. #define MSG_PEEK        $2             /* peek at incoming message */
  223. #define MSG_DONTROUTE   $4             /* send without using routing tables */
  224. #define MSG_EOR         $8             /* data completes record */
  225. #define MSG_TRUNC       $10            /* data discarded before delivery */
  226. #define MSG_CTRUNC      $20            /* control data lost before delivery */
  227. #define MSG_WAITALL     $40            /* wait for full request or error */
  228.  
  229. /*
  230.  * Header for ancillary data objects in msg_control buffer.
  231.  * Used for additional information with/about a datagram
  232.  * not expressible by flags.  The format is a sequence
  233.  * of message elements headed by cmsghdr structures.
  234.  */
  235. OBJECT cmsghdr
  236.     cmsg_len:ULONG,               /* data byte count, including hdr */
  237.     cmsg_level:LONG,             /* originating protocol */
  238.     cmsg_type:LONG              /* protocol-specific type */
  239. /* followed by  u_char  cmsg_data[]; */
  240.  
  241. /* given pointer to struct adatahdr, return pointer to data */
  242. #define CMSG_DATA(cmsg)         ((cmsg) + 1)
  243.  
  244. /* given pointer to struct adatahdr, return pointer to next adatahdr */
  245. /* --- got to do ---
  246. #define CMSG_NXTHDR(mhdr, cmsg) \
  247.         (((caddr_t)(cmsg) + (cmsg).cmsg_len + sizeof(struct cmsghdr) > \
  248.             (mhdr)->msg_control + (mhdr)->msg_controllen) ? \
  249.             (struct cmsghdr *)NULL : \
  250.             (struct cmsghdr *)((caddr_t)(cmsg) + ALIGN((cmsg)->cmsg_len)))
  251. */
  252.  
  253. #define CMSG_FIRSTHDR(mhdr)     ((mhdr).msg_control)
  254.  
  255. /* "Socket"-level control message types: */
  256. #define SCM_RIGHTS      $01            /* access rights (array of int) */
  257.  
  258. /*
  259.  * 4.3 compat sockaddr, move to compat file later
  260.  */
  261. OBJECT osockaddr
  262.     sa_family:UWORD,              /* address family */
  263.     sa_data[14]:BYTE            /* up to 14 bytes of direct address */
  264.  
  265. /*
  266.  * 4.3-compat message header (move to compat file later).
  267.  */
  268. OBJECT omsghdr
  269.     msg_name:PTR TO BYTE,        /* optional address */
  270.     msg_namelen:LONG,            /* size of address */
  271.     msg_iov:PTR TO iovec,        /* scatter/gather array */
  272.     msg_iovlen:LONG,             /* # elements in msg_iov */
  273.     msg_accrights:PTR TO BYTE,   /* access rights sent/received */
  274.     msg_accrightslen:LONG
  275.  
  276.  
  277.  
  278.